$(function(){
	$('#startDate,#endDate').date_input();
	
	//绑定添加权限事件
	$('#addPrivilege').click(function(){
		window.location.href = 'commonAction!forward.ac?url=system/privilegeAdd.jsp';
	});
	
	//更新事件
	$('#rs a.update').click(function(){
		var $this = $(this);
		var param = new Array();
		var url = 'sysPrivilegeAction!queryPrivilegeById.ac?';
		
		param.push('sysPrivilege.id=' + $this.parent().siblings('td:eq(0)').text());
		
		window.location.href = url + param.join('');
	});
	
	//删除事件
	$('#rs a.delete').click(function(){
		var $this = $(this);
		var param = new Array();
		
		param.push('sysPrivilege.id=' + $this.parent().siblings('td:eq(0)').text());
		
		jConfirm('您真的要删除些项吗?', '删除', function(rs) {
		    if(rs){
		    	$.ajax({
		    		type:'POST',
		    		dataType:'json',
		    		url:'sysPrivilegeAction!deletePrivilege.ac',
		    		data:param.join(''),
		    		beforeSend:function(){
						jLoading("正在操作，请稍后...");
					},
		    		success:function(rs){
		    			if(rs.flag){
		    				$this.parent().parent().remove();
		    				jUnloading();
		    			}
		    		}
		    	})
		    }
		});
	});
	
	/*
	 * 取得所有菜单
	 */
	$.ajax({
		type:'POST',
		dataType:'html',
		url:'sysMenuAction!queryMenuAll2.ac',
		beforeSend:function(){
			jLoading("正在取菜单，请稍后...");
		},
		success:function(rs){
			var $m = $('#sysMenu');
			$m.html(rs);
			setTimeout(function(){
				$m.val($('#sysMenuHidden').val());
				jUnloading();
			},10);
		}
	});
});